package com.example.designpatterns.prototype;

/**
 * 具体原型类
 * 实现克隆方法，返回自身的复制
 */
public class ConcretePrototype implements Prototype {
    private String id;
    private String name;
    private String category;
    
    public ConcretePrototype() {
    }
    
    public ConcretePrototype(String id, String name, String category) {
        this.id = id;
        this.name = name;
        this.category = category;
    }
    
    /**
     * 浅克隆实现
     */
    @Override
    public Prototype clone() {
        try {
            return (Prototype) super.clone();
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
            return null;
        }
    }
    
    // Getters and Setters
    public String getId() {
        return id;
    }
    
    public void setId(String id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getCategory() {
        return category;
    }
    
    public void setCategory(String category) {
        this.category = category;
    }
    
    @Override
    public String toString() {
        return "ConcretePrototype{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                ", category='" + category + '\'' +
                '}';
    }
} 